<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .div1 {
      width: 100px;
      height: 100px;
      background-color: red;
    }
    .div2 {
      width: 150px;
      height: 150px;
      background-color: blue;
    }
    .div3 {
      width: 200px;
      height: 200px;
      background-color: green;
    }
  </style>
</head>
<body>
  <div id="app">
    <p>修饰符</p>
    <p>事件修饰符</p>
    <p>1.prevent：阻止默认事件</p>
    <div class="div1" @contextmenu.prevent="showMenu"></div>
    <hr>
    <p>2.stop:阻止冒泡 </p>
    <div class="div3" @click="showClick(3)">
      <div class="div2" @click="showClick(2)">
        <div class="div1" @click.stop="showClick(1)"></div>
      </div>
    </div>
    <hr>
    <p>3.capture,优先执行；或者说将事件流改为捕获的方式</p>
    <div class="div3" @click.capture="showClick(3)">
      <div class="div2" @click.capture="showClick(2)">
        <div class="div1" @click.capture="showClick(1)"></div>
      </div>
    </div>
    <hr>
    <p>4.once：只执行一次。防抖节流</p>
    <div class="div3" @click="showClick(3)">
      <div class="div2" @click="showClick(2)">
        <div class="div1" @click.once="showClick(1)"></div>
      </div>
    </div>
    <p>5.self:只能由自己触发</p>
    <div class="div3" @click="showClick(3)">
      <div class="div2" @click.self="showClick(2)">
        <div class="div1" @click="showClick(1)"></div>
      </div>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {

      },
      methods: {
        showMenu() {
          console.log('你右键了');
        },
        showClick(num) {
          console.log('你点击了第'+num+'个div');
        }
      },
    })
  </script>
</body>
</html>